package com.sinosoft.hydra.um.services.component.dataimport;

/**
 * Created by Administrator on 2014/11/20.
 */
public class DataResult<T> {

    private String error;
    private boolean valid;
    private T source;

    public static <T> DataResult<T> ERROR(String error){
        DataResult<T> dataResult = new DataResult<T>();
        dataResult.setValid(false);
        dataResult.setError(error);
        return dataResult;
    }

    public static <T> DataResult<T> SUCCESS(T source){
        DataResult<T> dataResult = new DataResult<T>();
        dataResult.setSource(source);
        dataResult.setValid(true);
        return dataResult;
    }

    public static <T> DataResult<T> SUCCESS(){
        DataResult<T> dataResult = new DataResult<T>();
        dataResult.setValid(true);
        return dataResult;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public boolean isValid() {
        return valid;
    }

    public void setValid(boolean valid) {
        this.valid = valid;
    }

    public T getSource() {
        return source;
    }

    public void setSource(T source) {
        this.source = source;
    }
}
